﻿using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Drawing;

namespace G3.Controller
{
    public static class Parameters
    {
        private static bool loaded = false;

        public static void LoadParameters(String path)
        {
            parameters.Clear();
            StreamReader input = new StreamReader(path);
            while (!input.EndOfStream)
            {
                String line = input.ReadLine();
                line.Trim();
                if (!line.StartsWith("//") && line != "")
                {
                    String[] parts = line.Split(':');
                    if (parts.Length != 2) throw new Exception("invalid parameter format: " + line);
                    parameters.Add(parts[0].Trim(), parts[1].Trim());
                }
            }
            loaded = true;
            input.Close();
        }

        public static String GetParameter(String key)
        {
            if (!loaded) throw new Exception("parameters haven't been loaded");
            return parameters[key];
        }

        private static Dictionary<String, String> parameters = new Dictionary<String, String>();
    }
}
